package com.scx.controller.user;


import com.scx.result.Result;
import com.scx.service.FollowService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/follow")
@Api("C端-关注接口")
@Slf4j
public class FollowController {
    @Autowired
    private FollowService followService;

    @GetMapping("/or/not/{id}")
    @ApiOperation("是否关注")
    public Result isFollow(@PathVariable("id") Long followUserId) {
        return followService.isFollow(followUserId);
    }

    @PutMapping("/{id}/{isFollow}")
    @ApiOperation("关注or取关")
    public Result follow(@PathVariable("id") Long followUserId, @PathVariable("isFollow") Boolean isFollow) {
        log.info("关注?:{},{}", followUserId, isFollow.toString());
        return followService.follow(followUserId, isFollow);
    }

    @GetMapping("/common/{id}")
    @ApiOperation("共同关注")
    public Result commonFollow(@PathVariable("id") Long id) {
        log.info("共同关注：{}", id);
        return followService.followCommons(id);
    }
}
